From 7e279a535d1722ce6e32a6b0c4a84b5639d8c859 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Thu, 14 Dec 2023 12:34:15 -0500 Subject: Improve loading states --- src/app/groups/[groupId]/expenses/page.tsx | 46 +++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'src/app/groups/[groupId]') diff --git a/src/app/groups/[groupId]/expenses/page.tsx b/src/app/groups/[groupId]/expenses/page.tsx index 0ec5086..5285cb8 100644 --- a/src/app/groups/[groupId]/expenses/page.tsx +++ b/src/app/groups/[groupId]/expenses/page.tsx @@ -7,11 +7,13 @@ import { CardHeader, CardTitle, } from '@/components/ui/card' +import { Skeleton } from '@/components/ui/skeleton' import { getGroup, getGroupExpenses } from '@/lib/api' import { Plus } from 'lucide-react' import { Metadata } from 'next' import Link from 'next/link' import { notFound } from 'next/navigation' +import { Suspense } from 'react' export const metadata: Metadata = { title: 'Expenses', @@ -22,11 +24,6 @@ export default async function GroupExpensesPage({ }: { params: { groupId: string } }) { - const group = await getGroup(groupId) - if (!group) notFound() - - const expenses = await getGroupExpenses(groupId) - return (
@@ -46,13 +43,40 @@ export default async function GroupExpensesPage({
- + ( +
+
+ + +
+
+ +
+
+ ))} + > + +
) } + +async function Expenses({ groupId }: { groupId: string }) { + const group = await getGroup(groupId) + if (!group) notFound() + const expenses = await getGroupExpenses(group.id) + + return ( + + ) +} -- cgit v1.3